package chuangyi.com.org.ViewModel;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.databinding.Bindable;
import android.os.Bundle;
import android.view.View;

import chuangyi.com.org.DOMIHome.BR;
import chuangyi.com.org.DOMIHome.Fragments.CommonFragment;
import chuangyi.com.org.DOMIHome.HomeActivity;
import chuangyi.com.org.DOMIHome.R;
import chuangyi.com.org.DOMIHome.adapter.BindingListItem;

/**
 * 学习模块菜单项
 * Created by zxh on 16/11/15.
 */
public class MenuItem extends BindingListItem {
    private String code;
    private String title;

    @Bindable
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public MenuItem(Context context, int layoutId){
        super(context, layoutId);
    }

    /**
     * 全部版块里点击菜单项时执行此方法
     * @param view
     */
    public void onClickMenu(View view){
        Activity activity = (Activity)view.getContext();
        Intent intent = activity.getIntent();
        intent.putExtra("code", this.code);
        intent.putExtra("title", this.title);
        activity.setResult(Activity.RESULT_OK, intent);
        activity.finish();
    }
}
